const channel = (uni.getStorageSync('channel') || null)

const state = () => ({
	channel: channel , //前运行的频道
	statusBbarHeight: null,
	tabBerList: [{
			"pagePath": "pages/tabBar/home/index",
			"iconPath": "static/img/tabbar/icon-home-sm.png",
			"selectedIconPath": "static/img/tabbar/icon-home-active.png",
			"text": "首页"
		},
		{
			"pagePath": "pages/tabBar/order/index",
			"iconPath": "static/img/tabbar/icon-order-sm.png",
			"selectedIconPath": "static/img/tabbar/icon-order-active.png",
			"text": "订单"
		},
		{
			"pagePath": "pages/tabBar/customer/index",
			"iconPath": "static/img/tabbar/icon-customer-sm.png",
			"selectedIconPath": "static/img/tabbar/icon-customer-active.png",
			"text": "客户"
		},
		// {
		// 	"pagePath": "pages/tabBar/absent/index",
		// 	"iconPath": "static/img/tabbar/icon-absent-sm.png",
		// 	"selectedIconPath": "static/img/tabbar/icon-absent-active.png",
		// 	"text": "考勤"
		// },
		// {
		// 	"pagePath": "pages/tabBar/manage/index",
		// 	"iconPath": "static/img/tabbar/icon-manage-sm.png",
		// 	"selectedIconPath": "static/img/tabbar/icon-manage-active.png",
		// 	"text": "管理"
		// }
	]
})

const getters = {

}

const mutations = {
	updateStatusBbarHeight(state, height) {
		state.statusBbarHeight = height
		// 刷新页面后防止 height 清零
		try {
			uni.setStorageSync('statusBbarHeight', height);
		} catch (e) {}
	},
}

const actions = {
	setStatusBbarHeight({dispatch, commit, state }){
		const statusBarHeight = uni.getSystemInfoSync().statusBarHeight
		commit('updateStatusBbarHeight', statusBarHeight)
	},
}

export default {
	namespaced: true,
	getters,
	state,
	mutations,
	actions
}
